package com.ruoyi.web.controller.dy;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TlDyDoodsDetail;
import com.ruoyi.system.service.ITlDyDoodsDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 抖音商品详情Controller
 *
 * @author ruoyi
 * @date 2023-10-20
 */
@RestController
@RequestMapping("/system/dydetail")
public class TlDyDoodsDetailController extends BaseController
{
    @Autowired
    private ITlDyDoodsDetailService tlDyDoodsDetailService;

    /**
     * 查询抖音商品详情列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TlDyDoodsDetail tlDyDoodsDetail)
    {
        startPage();
        List<TlDyDoodsDetail> list = tlDyDoodsDetailService.selectTlDyDoodsDetailList(tlDyDoodsDetail);
        return getDataTable(list);
    }

    /**
     * 导出抖音商品详情列表
     */
    @Log(title = "抖音商品详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TlDyDoodsDetail tlDyDoodsDetail)
    {
        List<TlDyDoodsDetail> list = tlDyDoodsDetailService.selectTlDyDoodsDetailList(tlDyDoodsDetail);
        ExcelUtil<TlDyDoodsDetail> util = new ExcelUtil<TlDyDoodsDetail>(TlDyDoodsDetail.class);
        util.exportExcel(response, list, "抖音商品详情数据");
    }

    /**
     * 获取抖音商品详情详细信息
     */
    @GetMapping(value = "/{productId}")
    public AjaxResult getInfo(@PathVariable("productId") Long productId)
    {
        return success(tlDyDoodsDetailService.selectTlDyDoodsDetailByProductId(productId));
    }

    /**
     * 新增抖音商品详情
     */
    @Log(title = "抖音商品详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TlDyDoodsDetail tlDyDoodsDetail)
    {
        return toAjax(tlDyDoodsDetailService.insertTlDyDoodsDetail(tlDyDoodsDetail));
    }

    /**
     * 修改抖音商品详情
     */
    @Log(title = "抖音商品详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TlDyDoodsDetail tlDyDoodsDetail)
    {
        return toAjax(tlDyDoodsDetailService.updateTlDyDoodsDetail(tlDyDoodsDetail));
    }

    /**
     * 删除抖音商品详情
     */
    @Log(title = "抖音商品详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{productIds}")
    public AjaxResult remove(@PathVariable Long[] productIds)
    {
        return toAjax(tlDyDoodsDetailService.deleteTlDyDoodsDetailByProductIds(productIds));
    }
}
